package com.yss.sofa.report.engine.cell.visible.form;

import org.apache.commons.lang3.StringEscapeUtils;
import org.codehaus.jackson.map.annotate.JsonDeserialize;

import com.yss.sofa.report.engine.Const;
import com.yss.sofa.report.engine.cell.ReportCell;
import com.yss.sofa.report.engine.cell.visible.VisibleCell;
import com.yss.sofa.report.engine.json.FormCellDeserializer;

@JsonDeserialize(using=FormCellDeserializer.class)
public class FormCell extends VisibleCell{
	private static final long serialVersionUID = 3844599286780563597L;
	protected int inputType;
	protected String code;
	protected boolean allowBlank;
	protected boolean readOnly;
	protected boolean disabled;
	protected String value;
	protected String raw;
	protected void init(){
		super.init();
		this.type=Const.REPORT_CELL_TYPE_FORM;
		this.move=Const.CELL_MOVE_ABS;
		this.dataType=Const.CELL_DATA_TYPE_FORM;
		inputType=-1;
		this.allowBlank=false;
		this.readOnly=false;
		this.disabled=false;
		this.value=null;
		this.raw=null;
	}
	public void assignTo(ReportCell cell){
		FormCell _=(FormCell)cell;
		super.assignTo(_);
		_.inputType=this.inputType;
		_.code=this.code;
		_.allowBlank=this.allowBlank;
		_.readOnly=this.readOnly;
		_.disabled=this.disabled;
		_.value=this.value;
		_.raw=this.raw;
	}
	public FormCell create(){
		FormCell _=new FormCell();
		this.assignTo(_);
		return _;
	}
	public void setMove(int move){
	}
	public void setLazy(int lazy){
	}
	public void setDataType(int dataType) {
	}
	public int getInputType() {
		return inputType;
	}
	public void setInputType(int inputType) {
		this.inputType = inputType;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public boolean isReadOnly() {
		return readOnly;
	}
	public void setReadOnly(boolean readOnly) {
		this.readOnly = readOnly;
	}
	public boolean isDisabled() {
		return disabled;
	}
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}
	public String getValue() {
		return value;
	}
	public String getJsValue(){
		if(value==null){
			return "null";
		} else {
			return "'"+StringEscapeUtils.escapeEcmaScript(value)+"'";
		}
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getRaw() {
		return raw;
	}
	public String getJsRaw(){
		if(raw==null){
			return "null";
		} else {
			return "'"+StringEscapeUtils.escapeEcmaScript(raw)+"'";
		}
	}
	public void setRaw(String raw) {
		this.raw = raw;
	}
	public String getRenderSource(){
		throw new UnsupportedOperationException();
	}
	public boolean isAllowBlank() {
		return allowBlank;
	}
	public void setAllowBlank(boolean allowBlank) {
		this.allowBlank = allowBlank;
	}
	public boolean isCustom(){
		throw new UnsupportedOperationException();
	}
}
